﻿<UserControl x:Class="WiLinq.Codegen.Views.LinqCodeGenerationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm ="clr-namespace:WiLinq.CodeGen.ViewModels"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=vm:LinqCodeGenerationViewModel}"
                Height="500"
             Width="600" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0"
              Margin="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="28" />
                <RowDefinition Height="28" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TextBlock Text="Namespace:"
                       VerticalAlignment="Center"
                       Grid.Row="0"
                       Grid.Column="0" />
            <TextBlock Text="Language:"
                       VerticalAlignment="Center"
                       Grid.Row="1"
                       Grid.Column="0" />
            <TextBox Grid.Row="0"
                     VerticalAlignment="Center"
                     Text="{Binding Path=Namespace}"
                     Grid.Column="1"
                     Margin="5,2" />
            <StackPanel Orientation="Horizontal"
                        VerticalAlignment="Center"
                        Grid.Row="1"
                        Grid.Column="1">
                <RadioButton  Content="C#"
                              Margin="5,0"
                              GroupName="Language"
                              IsChecked="{Binding Path=CSharpCode}" />
                <RadioButton  Content="VB.Net"
                              GroupName="Language"
                              IsChecked="{Binding Path=VbNetCode}"
                              Margin="5,0" />
            </StackPanel>

        </Grid>
        <TabControl ItemsSource="{Binding Path=Classes}" 
                    ScrollViewer.VerticalScrollBarVisibility="Auto"
                    Grid.Row="1" 
                    TabStripPlacement="Left">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                        <CheckBox IsChecked="{Binding Path=Generate}" />
                        <TextBlock Text="{Binding Path=WorkItemType}" />
                    </StackPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
            <TabControl.ContentTemplate>
                <DataTemplate>
                    <Grid Margin="3" d:DataContext="{d:DesignInstance Type=vm:ModelClassDefinitionViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border  Margin="2"
                                 Background="#DDEFF9"
                                 BorderThickness="1"
                                 BorderBrush="#5AC5FF">
                            <Grid
                                Margin="6">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="30" />
                                    <RowDefinition Height="30" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="80" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Class name:"
                                           VerticalAlignment="Center"
                                           Grid.Row="0"
                                           Grid.Column="0" />
                                <TextBlock Text="Visibility:"
                                           VerticalAlignment="Center"
                                           Grid.Row="1"
                                           Grid.Column="0" />
                                <TextBox Grid.Row="0"
                                         VerticalAlignment="Center"
                                         Text="{Binding Path=ClassName}"
                                         Grid.Column="1"
                                         Margin="5,2" />
                                <StackPanel Orientation="Horizontal"
                                            VerticalAlignment="Center"
                                            Grid.Row="1"
                                            Grid.Column="1">
                                    <RadioButton  Content="Public"
                                                  Margin="5,0"                                                 
                                                  IsChecked="{Binding Path=IsPublic}" />
                                    <RadioButton  Content="Internal"                                                
                                                  IsChecked="{Binding Path=IsInternal}"
                                                  Margin="5,0" />
                                </StackPanel>
                            </Grid>
                        </Border>
                        <ScrollViewer Grid.Row="1"
                                      Margin="0,5">
                            <ItemsControl ItemsSource="{Binding Properties}"
                                          ScrollViewer.CanContentScroll="True"
                                          ScrollViewer.VerticalScrollBarVisibility="Auto">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="30" />
                                                <RowDefinition />
                                            </Grid.RowDefinitions>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{Binding ReferenceName}"
                                                           VerticalAlignment="Center"
                                                           FontWeight="Bold" />
                                                <Image Source="..\Media\Read_16.png"
                                                       Margin="3,0"
                                                       Width="16"
                                                       Height="16"
                                                       VerticalAlignment="Center" />
                                                <Image Source="..\Media\Write_16.png"
                                                       Name="writeImg"
                                                       Width="16"
                                                       VerticalAlignment="Center"
                                                       Height="16"
                                                       Margin="3,0" />
                                                <TextBlock Text="{Binding Type}"
                                                           VerticalAlignment="Center"
                                                           FontStyle="Italic" />
                                            </StackPanel>
                                            <Grid Grid.Row="1"
                                                  Margin="10,0,0,0">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="100" />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="0"
                                                           Grid.Column="0"
                                                           Text="Property name:" />
                                                <TextBox Grid.Row="0"
                                                         Grid.Column="1"
                                                         Text="{Binding PropertyName}" />
                                            </Grid>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <DataTrigger  Binding="{Binding Path=IsReadOnly}"
                                                          Value="true">
                                                <Setter TargetName="writeImg"
                                                        Property="Visibility"
                                                        Value="Collapsed" />
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>

                    </Grid>

                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>

        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="5">
            <Button Content="Generate classes" VerticalAlignment="Stretch" Command="{Binding GenerateClassesCommand}" />
        </StackPanel>
    </Grid>
</UserControl>
